package cn.edu.scau.cmi.chenjiale.integration.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;

import cn.edu.scau.cmi.chenjiale.integration.entity.Student;
import cn.edu.scau.cmi.chenjiale.integration.utils.DBUtils;

/**
 * 学生Dao
 * 
 * @author chen.jiale
 * @date 2019/05/18
 *
 */
public class StudentDao {
  
	public boolean add(Student student) {
		Session session = DBUtils.session();
		session.saveOrUpdate(student);
		DBUtils.commitTransactionAndClose(session);
		return true;
	}
	
	@SuppressWarnings("unchecked")
	public List<Student> list() {
		Session session = DBUtils.session();
		Query query = session.createQuery("from Student");
		List<Student> studentList = query.list();
		return studentList;
	}
	
}
